{include file="Public:header" /}
<body>
  {include file="Public:top_nav" /}

  <div class="content content-nav-base commodity-content">
    {include file="Public:category_nav" /}
    <div class="commod-cont-wrap">
      <div class="commod-cont w1200 layui-clear">
        <div class="left-nav">
          <div class="title">所有分类</div>
          <div class="list-box">
            {volist name="category" id="cate"}
            <dl>
              <dt>{$cate.title}</dt>
              {volist name="$cate['child']" id="vo"}
              <dd><a href="{:url('goods/index',['id'=>$vo['id']])}" {eq name="vo.id" value="$id"}style="color:#ff0000"{/eq}>{$vo.title}</a></dd>
              {/volist}
            </dl>
            {/volist}
          </div>
        </div>
        <div class="right-cont-wrap">
          <div class="right-cont">
            <div class="sort layui-clear">
              <a class="active" href="javascript:;" event = 'volume'>销量</a>
              <a href="javascript:;" event = 'price'>价格</a>
              <a href="javascript:;" event = 'newprod'>新品</a>
              <a href="javascript:;" event = 'collection'>收藏</a>
            </div>
            <div class="prod-number">
              <span>{$count}</span>
            </div>
            <div class="cont-list layui-clear" id="list-cont">
              {volist name="goods" id="vo"}
              <div class="item">
                <div class="img">
                  <a href="{:url('goods/details',['id'=>$vo.id])}"><img src="{$vo.img}" title="{$vo.name}" style="display: block;margin: 0 auto;"></a>
                </div>
                <div class="text">
                  <p class="title">{$vo.name}</p>
                  <p class="price">
                    <span class="pri">{if condition="($vo['new_price']=='0') or ($vo['new_price']=='0.00')"}￥{$vo.price|decimal}{else /}活动价：￥{$vo.new_price|decimal}{/if}</span>
                    <span class="nub">{$vo.payman}付款</span>
                  </p>
                </div>
              </div>
              {/volist}
            </div>
            <!-- 模版引擎导入 -->
            <!-- <script type="text/html" id="demo">
              {{# layui.each(d.menu.milk.content,function(index,item){}}
                <div class="item">
                  <div class="img">
                    <a href="javascript:;"><img src="{{item.img}}"></a>
                  </div>
                  <div class="text">
                    <p class="title"></p>
                    <p class="price">
                      <span class="pri">{{item.pri}}</span>
                      <span class="nub">{{item.nub}}</span>
                    </p>
                  </div>
                </div>
              {{# }); }}
            </script> -->
            <div id="demo0" style="text-align: center;">
              {$page|raw}
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
<script>

  layui.config({
    base: '__STATIC__/index/static/js/util/' //你存放新模块的目录，注意，不是layui的模块目录
  }).use(['form','mm','laypage','jquery','layer'],function(){
    var form = layui.form,laypage = layui.laypage,$ = layui.$,mm = layui.mm,layer = layui.layer;


    $('.main-nav .inner-cont2 a').eq(0).addClass('active');
    $('.sort a').on('click',function(){
      $(this).addClass('active').siblings().removeClass('active');

      $.ajax({
        url:"{:url('Goods/index')}",
        method:'post',
        data:{'event':$(this).attr('event')},
        dataType:'JSON',
        success:function(res){
          if(res.code='1001'){
            console.log(res.data);
          }
          else{
            console.log(res.msg);
          }
        },
        error:function(err){
          layer.msg(err);
        }
      });
    });

    $('.list-box dt').on('click',function(){
      if($(this).attr('off')){
        $(this).removeClass('active').siblings('dd').show()
        $(this).attr('off','')
      }else{
        $(this).addClass('active').siblings('dd').hide()
        $(this).attr('off',true)
      }
    });
    // 搜索资源
    form.on('submit(search)', function(data){
        var param = data.field;
        var list = [];
        $.ajax({
            type:'post',
            url:"{:url('index/goods/index')}",
            data:param,
            dataType:'JSON',
            success:function(res){
                if (res.code=='1001'){
                    layer.msg(res.msg);
                    console.log(res.data);
                    layui.each(res.data,function(index,items){
                      $('#list-cont').empty();
                      var html = "";
                      html = "<div class='item'> \
                        <div class='item'> \
                          <a href='"+'/details/id/'+items.id+"'><img src='"+items.img+"' title='"+items.name+"' style='display: block;margin: 0 auto;'></a> \
                        </div> \
                        <div class='text'> \
                          <p class='title'>'"+items.name+"'</p> \
                          <p class='price'> \
                            <span class='pri'>原来的价格</span> \
                            <span class='nub'>'"+items.payman+"'付款</span> \
                          </p> \
                        </div> \
                      </div>";
                      list.push(html);
                    })
                    $('#list-cont').append(list);
                    list = [];
                } else if(res.code=='1004'){
                    layer.msg(res.msg);
                }
            },
            error:function (ress) {
                layer.msg(ress);
                setTimeout(function(){
                  location.href = '{:url("goods/index")}';
                },2000);
            }
        })
        return false;
    });
});
</script>
</body>
</html>